package com.zhuss.common;

import io.swagger.annotations.ApiModel;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.zhuss.exception.ExceptionCode;
import com.zhuss.exception.OceanException;

@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value="返回值vo",description="返回值vo对象")
public class ResponseSucc {
	
	private Integer code;
	
	private String msg;
	
	private Response data = new DefaultDataResponse();
	
	public ResponseSucc(Object data) {
		this.code = 0;
		this.msg = "操作成功!";
		if (data instanceof DataResponse) {
			this.data = (Response) data;
		} else {
			this.data.setData(data);
		}
	}
	
	public ResponseSucc() {
		this.code = 0;
		this.msg = "操作成功!";
	}
	
	public ResponseSucc(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public ResponseSucc(OceanException e) {
		this.msg = e.getMsg();
		this.code = e.getCode();
		this.data = e.getData();
	}
	
	public ResponseSucc(ExceptionCode e) {
		this.msg = e.getMsg();
		this.code = e.getCode();
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Response getData() {
		return data;
	}

	public void setData(Response data) {
		this.data = data;
	}

}
